const fp = require('lodash/fp')
const { Maybe, Container } = require('./support')
let maybe = Maybe.of([5, 6, 1])
let ex1 = (x) => {
    let f1 = fp.map(fp.add(x))
    return maybe.map(f1);
}
// console.log(ex1(3));


// =========2
let xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'ti', 'do'])
let ex2 = () => {
    return xs.map(fp.first)._value;
}
console.log(ex2());


//==========3
let safeprop = fp.curry(function (x, o){
    return Maybe.of(o[x]);
});
let user = {id: 2, name: 'albert'}
let ex3 = (user) => {
    let f = safeprop('name')(user).map(fp.first)._value;
    return f
}
console.log(ex3(user));

//=========4
// let ex4 = function (n) {
//     if(n) {
//         return parseInt(n);
//     }
// }

let ex4 = function (n) {
    // if(n){
    //   return parseInt(n)
    // }
    return Maybe.of(n).map(parseInt)._value
}
console.log(ex4(1));

